package cn.online.action;

import java.util.List;

import cn.online.model.Course;
import cn.online.model.Teacher;
import cn.online.service.CourseService;
import cn.online.service.TeacherService;

import com.opensymphony.xwork2.ActionSupport;

public class TeacherAction extends ActionSupport {
	
	private TeacherService teacherService;
	private CourseService courseService;
	private Teacher teacher;
	private List<Teacher> teacherL;
	private Integer tids[];
	private List<Course> courseL;
	
	
	public List<Course> getCourseL() {
		return courseL;
	}
	public void setCourseL(List<Course> courseL) {
		this.courseL = courseL;
	}
	public CourseService getCourseService() {
		return courseService;
	}
	public void setCourseService(CourseService courseService) {
		this.courseService = courseService;
	}
	public Teacher getTeacher() {
		return teacher;
	}
	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}
	public List<Teacher> getTeacherL() {
		return teacherL;
	}
	public void setTeacherService(TeacherService teacherService) {
		this.teacherService = teacherService;
	}
	public void setTids(Integer tids[]) {
		this.tids = tids;
	}
	
	public String add(){
		courseL = courseService.findAll();
		return SUCCESS;
	}
	
	public String save(){
		teacherService.insert(teacher);
		return SUCCESS;
	}
	public String deleteTeachers(){
		if(tids==null)
			return INPUT;
		teacherService.deleteTeachers(tids);
		return SUCCESS;
	}
	
	public String update(){
		teacherService.updateTeacher(teacher);
		return SUCCESS;
	}
	
	public String load(){
		if(tids==null)
			return INPUT;
		teacher=teacherService.findById(tids[0]);
		courseL = courseService.findAll();
		return SUCCESS;
	}
	
	public String list(){
		teacherL=teacherService.getTeacherList();
		return SUCCESS;
	}
}
